@echo off
setlocal

:: bootstrap
pushd %~dp0
call _configure.bat
popd


:: start
set branch=%1
set dir=%BRANCHES_DIR%
set docroot=%BRANCH_HOSTING_PATH%


if [%branch%] equ [trunk] (

	set branch=trunk-Stable

)



:: declare branch
:redefine_branch
if not defined branch (
	
	set /P branch=Enter branch name: 
	
	if not defined branch (
		
		goto :redefine_branch
		
	)
	
)

:: validate branch

set branch_path=%dir%\%branch%

if not exist %branch_path%\nul (

	echo branch do not exist %branch_path%
	
	goto :redefine_branch
)

:: remove current link

if exist %docroot% (

	if exist %docroot%\nul (
	
		rmdir /S /Q %docroot%
		
	) else (
	
		del /F /Q %docroot%
	)
)

:: create link!
call mklink /D %docroot% %branch_path%




goto :end

:show_usage
echo usage: sb [BRANCH_NAME]
goto :eof

:end
endlocal